import { _decorator, Button, Component, Node } from 'cc';
import { UIBase } from '../../ISUtility/Script/UI/UIBase';
import { Sound } from '../../ISUtility/Script/Sound';
const { ccclass, property } = _decorator;

@ccclass('UISetting')
export class UISetting extends UIBase {

    @property({ type: Button })
    public CloseBtn: Button = null;

    @property({ type: Button })
    public BGMBtn: Button = null;

    @property({ type: Button })
    public SoundBtn: Button = null;


    start() {
        this.CloseBtn.node.on(Button.EventType.CLICK, this.Close, this);
        this.BGMBtn.node.on(Button.EventType.CLICK, this.onBGMBtn_Click, this);
        this.SoundBtn.node.on(Button.EventType.CLICK, this.onSoundBtn_Click, this);
    }

    update(deltaTime: number) {

    }

    private onBGMBtn_Click() {
        if(Sound.inst.BGMVolume > 0) {
            Sound.inst.BGMVolume = 0;
        } else {
            Sound.inst.BGMVolume = 0.5;
        }
    }

    private onSoundBtn_Click() {
        if(Sound.inst.SoundVolume > 0) {
            Sound.inst.SoundVolume = 0;
        } else {
            Sound.inst.SoundVolume = 0.5;
        }
    }
}


